<?php
session_start();
require_once '../header.php';
function __autoload($className)
	{
    	require_once('../class/' . $className . '.class.php');
	}
session::need_member();
$UserId=session::getuserid();
if(!empty($_POST))
{
		$lracc=rtrim(trim($_POST['lraccount']));
		$lrbatch=rtrim(trim($_POST['lrbatch']));
		$Check=$lracc."".$lrbatch;
		$ReturnCheck=verify::check($Check);
		$CheckIsset=user::checkpermission('lrverifier', "verifier=$lrbatch", '1=1');
		if(($ReturnCheck=='0')&&($CheckIsset=='0'))
		{
			
			$Amount=lrxml::searchistory($lrbatch);
			if(abs($Amount)>0)
			{
				$Amount=abs($Amount);
				if($Amount>=100)
				{
					$AmountAfterPlus=(ceil($Amount/20)+$Amount);
				}
				else 
				{
					$AmountAfterPlus=$Amount;
				}
				database::Insert('lrverifier', array('verifier' => $lrbatch));
				$Date=date("Y-m-d");
				database::Insert('payment', array('userid' => $UserId,'date' => $Date,'amount' => $AmountAfterPlus,'reason' => "DEPOSIT $Amount FROM LR Account: $lracc : $lrbatch ",'lr' => $Amount));
				database::Update('userinfo',array('userid' => $UserId),array('money' => array( "money + {$AmountAfterPlus}"),'deposit' => array("deposit + {$Amount}")));
				$_SESSION["erro"]="Successful ! Your Balance has been Added";
				redirect::location("../membercp.php");
			}
			else 
			{
				$_SESSION["erro"]="Do not Find Your Payment Batch";
				redirect::location("../membercp.php");
			}
			
		}
		else
		{
			$_SESSION["erro"]="This batch has been Used or Your input batch has some problem, plz check again";
			redirect::location("../membercp.php");
		}
		
}
else
{
	$webroot="../";
	require_once '../html/template.php';
	?>
	
	<form name="sendmoney" action="index.php" method="POST" />
		<table width="93%" border="0" style=" margin-left:25px; padding-top:10px; padding-bottom:30px; margin-right:25px">
		 <tr>
    <th scope="col" colspan="3">- Send the amount you want to add to account:<font class="classmenu"> U8276640</font></th>
    </tr>
    <tr>
    <th scope="col" colspan="3" >- Remember Our Account name is: <font class="classmenu">Good CC Shop</font></th>
    </tr>
    <tr>
    <th scope="col" colspan="3" >- Copy the bath of payment and put in these text box</th>
    </tr>

  <tr>
    <th scope="col" colspan="3" >- Enter Your account and the amount you want to add</th>
    </tr>
  <tr>
    <th scope="col">Your LR ACCOUNT</th>
    <th scope="col">Batch</th>
     </tr>
  <tr>
     <th scope="col"><input type="text" name="lraccount"  /></th>
     <th scope="col"><input type="text" name="lrbatch"  /></th>
  
  </tr>
   <tr>
    <td colspan="3" align="center"><input name="submit" type="submit" value="submit" /></td>
    </tr>
    
    
  
        </form>
    </table>
    <center> <img src="../images/payment.png" /></center>
    </div>
  
	<?php 
}

?>